<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\member\model;

class Rights extends \app\BaseModel
{
    protected $name = "massage_member_rights";
    public function initData($uniacid)
    {
        $arr = ["send_coupon" => ["title" => "会员送券", "show_title" => "尊享优券", "icon" => "https://lbqny.migugu.com/admin/anmo/member/kaquan.png"], "appoint_service" => ["title" => "指定服务购买", "show_title" => "专属服务", "icon" => "https://lbqny.migugu.com/admin/anmo/member/fuwu.png"], "customer_service" => ["title" => "专属客服", "show_title" => "专属客服", "icon" => "https://lbqny.migugu.com/admin/anmo/member/kefu.png"], "first_refund" => ["title" => "会员优先退款", "show_title" => "极速退款", "icon" => "https://lbqny.migugu.com/admin/anmo/member/tuikuan.png"]];
        $key = "member_init_rights";
        incCache($key, 1, $uniacid);
        if(getCache($key, $uniacid) == 1) {
            foreach ($arr as $key => $value) {
                $dis = ["uniacid" => $uniacid, "key" => $key];
                $find = $this->dataInfo($dis);
                if(empty($find)) {
                    $insert = ["uniacid" => $uniacid, "key" => $key, "title" => $value["title"], "show_title" => $value["show_title"], "rights_icon" => $value["icon"], "is_admin" => 1];
                    $this->dataAdd($insert);
                }
            }
        }
        decCache($key, 1, $uniacid);
        return true;
    }
    public function dataAdd($data)
    {
        $data["create_time"] = time();
        $res = $this->insert($data);
        return $res;
    }
    public function dataUpdate($dis, $data)
    {
        $res = $this->where($dis)->update($data);
        return $res;
    }
    public function dataList($dis, $page)
    {
        $data = $this->where($dis)->order("top desc,id desc")->paginate($page)->toArray();
        return $data;
    }
    public function dataInfo($dis)
    {
        $data = $this->where($dis)->find();
        return !empty($data) ? $data->toArray() : [];
    }
}

?>